<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户定位确认</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 15px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            text-align: center;
        }

        .header h1 {
            font-size: 2.5em;
            margin-bottom: 10px;
            font-weight: 300;
        }

        .header p {
            font-size: 1.1em;
            opacity: 0.9;
        }

        .content {
            padding: 40px;
        }

        .section {
            margin-bottom: 40px;
            background: #f8f9fa;
            border-radius: 10px;
            padding: 25px;
            border-left: 4px solid #667eea;
        }

        .section h2 {
            color: #333;
            margin-bottom: 20px;
            font-size: 1.5em;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .form-group {
            margin-bottom: 25px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #555;
            font-size: 1.1em;
        }

        .form-group input,
        .form-group textarea {
            width: 100%;
            padding: 15px;
            border: 2px solid #e1e5e9;
            border-radius: 8px;
            font-size: 16px;
            transition: all 0.3s ease;
            font-family: inherit;
        }

        .form-group input:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .form-group textarea {
            resize: vertical;
            min-height: 120px;
        }

        .controls {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
        }

        .btn {
            padding: 12px 30px;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
        }

        .btn-secondary {
            background: #6c757d;
            color: white;
        }

        .btn-secondary:hover {
            background: #5a6268;
            transform: translateY(-2px);
        }

        .btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .output {
            background: #f8f9fa;
            border: 2px solid #e1e5e9;
            border-radius: 8px;
            padding: 20px;
            min-height: 200px;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            white-space: pre-wrap;
            overflow-y: auto;
            color: #333;
        }

        .status {
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            font-weight: 600;
        }

        .status.success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .status.error {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        .status.info {
            background: #d1ecf1;
            color: #0c5460;
            border: 1px solid #bee5eb;
        }

        .loading {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid #f3f3f3;
            border-top: 3px solid #667eea;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .example-text {
            background: #e9ecef;
            padding: 15px;
            border-radius: 8px;
            margin-top: 10px;
            font-size: 14px;
            color: #6c757d;
        }

        .token-info {
            background: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🎯 用户定位确认</h1>
            <p>通过一句话描述和详细文档进行用户定位分析</p>
        </div>

        <div class="content">
            <div class="section">
                <h2>🔧 服务配置</h2>
                <div class="form-group">
                    <label for="baseUrl">服务端地址:</label>
                    <input type="text" id="baseUrl" value="http://localhost:8080" placeholder="请输入服务端地址">
                </div>
                <div class="form-group">
                    <label for="token">认证Token:</label>
                    <input type="text" id="token" placeholder="请输入用户认证Token">
                </div>
                <div class="token-info">
                    <strong>💡 提示：</strong>Token将在请求头中携带，用于用户身份验证
                </div>
            </div>

            <div class="section">
                <h2>📝 一句话描述</h2>
                <div class="form-group">
                    <label for="desc">一句话描述 (必填):</label>
                    <input type="text" id="desc" placeholder="请用一句话描述您的业务或需求...">
                </div>
                <div class="example-text">
                    <strong>示例：</strong>我是一家做男性健康咨询的机构，主要面向28-45岁男性群体，提供健康咨询服务
                </div>
            </div>

            <div class="section">
                <h2>📄 详细定位文档</h2>
                <div class="form-group">
                    <label for="message">定位文档 (支持Markdown格式):</label>
                    <textarea id="message" placeholder="请详细描述您的业务情况、目标客户、营销需求等信息..."></textarea>
                </div>
                <div class="example-text">
                    <strong>Markdown格式示例：</strong><br>
                    # 业务概况<br>
                    - 行业：男性健康咨询<br>
                    - 目标客户：28-45岁男性<br>
                    - 主要服务：健康咨询、产品推荐<br><br>
                    ## 营销需求<br>
                    - 渠道：微信、抖音<br>
                    - 内容：健康知识、产品介绍<br>
                    - 风格：专业、可信赖
                </div>
            </div>

            <div class="section">
                <h2>🚀 操作控制</h2>
                <div class="controls">
                    <button id="submitBtn" class="btn btn-primary">
                        <span id="submitIcon">📤</span>
                        <span id="submitText">提交定位确认</span>
                    </button>
                    <button id="clearBtn" class="btn btn-secondary">🗑️ 清空结果</button>
                    <button id="exampleBtn" class="btn btn-secondary">📋 加载示例</button>
                </div>
            </div>

            <div class="section">
                <h2>📊 提交结果</h2>
                <div id="status" class="status info">等待提交...</div>
                <div id="output" class="output">等待提交...</div>
            </div>
        </div>
    </div>

    <script>
        // 获取DOM元素
        const baseUrlEl = document.getElementById('baseUrl');
        const tokenEl = document.getElementById('token');
        const descEl = document.getElementById('desc');
        const messageEl = document.getElementById('message');
        const outputEl = document.getElementById('output');
        const statusEl = document.getElementById('status');
        const submitBtn = document.getElementById('submitBtn');
        const clearBtn = document.getElementById('clearBtn');
        const exampleBtn = document.getElementById('exampleBtn');
        const submitIcon = document.getElementById('submitIcon');
        const submitText = document.getElementById('submitText');

        function init() {
            submitBtn.addEventListener('click', submitUserLocationFix);
            clearBtn.addEventListener('click', clearOutput);
            exampleBtn.addEventListener('click', loadExample);
            
            // 设置默认值
            tokenEl.value = 'test-token-123';
            descEl.value = '我是一家做男性健康咨询的机构，主要面向28-45岁男性群体，提供健康咨询服务';
        }

        async function submitUserLocationFix() {
            const message = messageEl.value.trim();
            const desc = descEl.value.trim();
            const token = tokenEl.value.trim();
            const baseUrl = baseUrlEl.value.trim();

            if (!message) {
                showStatus('请输入定位文档', 'error');
                return;
            }

            if (!desc) {
                showStatus('请输入一句话描述', 'error');
                return;
            }

            if (!token) {
                showStatus('请输入认证Token', 'error');
                return;
            }

            try {
                setLoading(true);
                clearOutput();
                showStatus('正在提交用户定位确认...', 'info');

                const requestData = {
                    message: message,
                    desc: desc
                };

                const response = await fetch(`${baseUrl}/api/client/index/userLocationFix`, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'token': token
                    },
                    body: JSON.stringify(requestData)
                });

                if (!response.ok) {
                    throw new Error(`HTTP ${response.status}: ${response.statusText}`);
                }

                const result = await response.json();

                if (result.code === 200) {
                    showStatus('用户定位确认提交成功！', 'success');
                    appendOutput('提交成功:\n');
                    appendOutput(JSON.stringify(result.data, null, 2));
                } else {
                    throw new Error(result.message || '提交失败');
                }

            } catch (error) {
                showStatus(`错误: ${error.message}`, 'error');
                appendOutput(`错误: ${error.message}`);
            } finally {
                setLoading(false);
            }
        }

        function clearOutput() {
            outputEl.textContent = '';
            statusEl.className = 'status info';
            statusEl.textContent = '等待提交...';
        }

        function appendOutput(content) {
            outputEl.textContent += content;
            outputEl.scrollTop = outputEl.scrollHeight;
        }

        function showStatus(message, type) {
            statusEl.className = `status ${type}`;
            statusEl.textContent = message;
        }

        function setLoading(loading) {
            submitBtn.disabled = loading;
            if (loading) {
                submitIcon.innerHTML = '<div class="loading"></div>';
                submitText.textContent = '提交中...';
            } else {
                submitIcon.textContent = '📤';
                submitText.textContent = '提交定位确认';
            }
        }

        function loadExample() {
            const exampleDesc = '我是一家做男性健康咨询的机构，主要面向28-45岁男性群体，提供健康咨询服务';
            const exampleMessage = `# 业务概况

## 基本信息
- **行业**: 男性健康咨询
- **细分领域**: 男性健康管理
- **业务区域**: 全国线上服务

## 目标客户群体
- **年龄**: 28-45岁男性
- **收入水平**: 中等收入及以上
- **职业类型**: 白领、管理层、自由职业者
- **地理分布**: 一线城市、新一线城市为主
- **生活方式**: 工作繁忙型、健康意识较强

## 客户需求分析
### 显性需求
- 健康问题咨询
- 专业医疗建议
- 产品推荐服务

### 隐性需求
- 隐私保护需求
- 便捷服务体验
- 专业可信赖感

### 情感需求
- 健康安全感
- 被理解和支持
- 生活品质提升

## 营销推广需求
### 渠道偏好
- 微信生态（公众号、小程序）
- 抖音短视频
- 搜索引擎优化

### 内容重点
- 健康知识科普
- 专业医疗内容
- 用户案例分享

### 品牌定位
- 专业可信赖
- 隐私保护严格
- 服务贴心周到

### 沟通风格
- 专业但亲和
- 严谨但易懂
- 重视用户隐私`;

            descEl.value = exampleDesc;
            messageEl.value = exampleMessage;
            showStatus('已加载示例数据', 'info');
        }

        // 页面加载完成后初始化
        document.addEventListener('DOMContentLoaded', init);
    </script>
</body>
</html> 